package GraphType.Movement_of_arr;

public class SolutionDFS {
    static int MIN_STEP = 999;
    static int[] visit = new int[100];

    public static void main(String[] args) {
        int n = 10, start = 2, end = 7, cur = 0;
        dfs(n, start, end, cur);
        System.out.println(MIN_STEP);
    }

    private static void dfs(int n, int start, int end, int curStep) {
        if (start == end) {
            MIN_STEP = Math.min(curStep, MIN_STEP);
            return;
        }
        if (start >= 0 && start <= n && visit[start] == 0) {
            visit[start] = 1;
            dfs(n, start + 1, end, curStep + 1);
            dfs(n, start - 1, end, curStep + 1);
            dfs(n, start * 2, end, curStep + 1);
            visit[start] = 0;
        }

    }
}
